package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.fabu.FabuTbBean;
import com.lwj.liwanjia.impl.FabuTbView;
import com.lwj.liwanjia.model.FbTbUploadModel;

import java.io.File;

import rx.Subscriber;

/**
 * Created by Administrator on 2018/1/14.
 */

public class FbTbUploadPresenter {
    private FabuTbView fabuTbView;
    private FbTbUploadModel fbTbUploadModel;

    public FbTbUploadPresenter(FabuTbView fabuTbView) {
        this.fabuTbView = fabuTbView;
        fbTbUploadModel = new FbTbUploadModel();
    }

    public void uploadTb(File file, String token) {
        fbTbUploadModel.uploadTb(file, token, new Subscriber<FabuTbBean>() {
            @Override
            public void onCompleted() {
                fabuTbView.hideProgress();
            }

            @Override
            public void onError(Throwable e) {
                fabuTbView.showError((Exception) e);
                fabuTbView.hideProgress();
            }

            @Override
            public void onNext(FabuTbBean fabuTbBean) {
                fabuTbView.uploadTb(fabuTbBean);
            }

            @Override
            public void onStart() {
                super.onStart();
                fabuTbView.showProgress();
            }
        });
    }
}
